////
////  CustomOfferViewController.m
////  WapsDemo
////
////  Created by 万普世纪 on 14-4-10.
////
////
//
//#import "CustomOfferViewController.h"
//#import "CustomOfferTableViewCell.h"
//
//
//#define IOS7 (([UIDevice currentDevice].systemVersion.intValue)>=7) //判断是否为IOS7的系统
//#define WAPS_NAVBAR_7_HEIGHT   64
//#define WAPS_NAVBAR_6_HEIGHT   44
//#define WAPS_STATUSBAR_HEIGHT  20
//
//@interface CustomOfferViewController ()
//{
//    UIActivityIndicatorView *actIndicator;//下载指示器
//    WPListCustom *wapCustom;//公开接口对象
//    WapsModel *model;//用来保存点击cell之后的model
//    UIView *contentView;//插屏广告画布
//    UIBarButtonItem *leftItem;
//    UIBarButtonItem *rightItem;
//    WPListCustom *downLoadWapsCustom;
//    UINavigationBar *navBar;//自定义导航栏
//    UINavigationItem *navBarItem;
//    float h;
//}
//@end
//
//@implementation CustomOfferViewController
//
//- (void)dealloc
//{
//    myTableView = nil;
//    self.selectModel = nil;
//    actIndicator = nil;
//    model = nil;
//    contentView = nil;
//    leftItem = nil;
//    rightItem = nil;
//    downLoadWapsCustom = nil;
//    self.dataArray = nil;
//    wapCustom = nil;
//    navBar = nil;
//    navBarItem = nil;
//    SUPER_DEALLOC;
//}
//- (void)viewDidUnload
//{
//    [super viewDidUnload];
//}
//
//- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
//{
//    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
//    if (self) {
//        // Custom initialization
//    }
//    return self;
//}
//
//- (void)viewWillAppear:(BOOL)animated
//{
////    [[UIApplication sharedApplication] setStatusBarHidden:NO];
//}
//
//- (void)viewDidLoad
//{
//    [super viewDidLoad];
//    // Do any additional setup after loading the view.
//
//    
////    [[UIApplication sharedApplication] setStatusBarHidden:NO];
//    
//    self.view.backgroundColor = [UIColor clearColor];
//
//    downLoadWapsCustom = [[WPListCustom alloc] init];
//    
//    float statusBarHeightY = 0;
//    CGRect viewBounds = [[UIScreen mainScreen] applicationFrame];//不包含状态栏的Rect
//    statusBarHeightY = viewBounds.origin.y - self.view.frame.origin.y;
//    CGFloat statusBarHeightX = viewBounds.origin.x -self.view.frame.origin.x;
//    
//    h = 0;
//    //判断设备方向
//    if ([UIApplication sharedApplication].statusBarOrientation == UIDeviceOrientationLandscapeLeft ||[UIApplication sharedApplication].statusBarOrientation == UIDeviceOrientationLandscapeRight)     {//
//        if (statusBarHeightX && statusBarHeightX >= 20.0f) {
//            if (IOS7) {//判断操作系统版本
//                h = WAPS_NAVBAR_7_HEIGHT;
//            }else{
//                h = WAPS_NAVBAR_6_HEIGHT;
//            }
//        }else{
//            if (IOS7) {
//                h = WAPS_NAVBAR_7_HEIGHT - WAPS_STATUSBAR_HEIGHT;
//            }else{
//                h = WAPS_NAVBAR_6_HEIGHT;
//            }
//        }
//    }else{//
//        if (statusBarHeightY && statusBarHeightY >= 20.0f) {
//            if (IOS7) {
//                h = WAPS_NAVBAR_7_HEIGHT;
//            }else{
//                h = WAPS_NAVBAR_6_HEIGHT;
//            }
//        }else{
//            if (IOS7) {
//                h = WAPS_NAVBAR_7_HEIGHT - WAPS_STATUSBAR_HEIGHT;
//            }else{
//                h = WAPS_NAVBAR_6_HEIGHT;
//            }
//        }
//    }
//    
//    //初始化导航条
//    CGRect navBarFrame = CGRectMake(0, 0, self.view.frame.size.width, h);
//    navBar = [[UINavigationBar alloc] initWithFrame:navBarFrame];
//    [self.view addSubview:navBar];
//    
//
//    //导航栏返回按钮
////    leftItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStyleBordered target:self action:@selector(buttonBack:)];
////    leftItem.tag = 101;
//    
//    //导航栏RightItem刷新按钮
//    rightItem = [[UIBarButtonItem alloc] initWithTitle:@"刷新" style:UIBarButtonItemStyleBordered target:self action:@selector(buttonBack:)];
//    rightItem.tag = 102;
//    
//    navBarItem = [[UINavigationItem alloc] initWithTitle:@"免费获取积分"];
//    [navBarItem setLeftBarButtonItem:leftItem];
//    [navBarItem setRightBarButtonItem:rightItem];
//    navBar.items = [NSArray arrayWithObject:navBarItem];
//    [navBar setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
//    
//    //初始化myTableView
//    CGRect rect = CGRectMake(0, h, self.view.frame.size.width, self.view.frame.size.height - 45);
//    myTableView  = [[UITableView alloc] initWithFrame:rect style:UITableViewStylePlain];
//    myTableView.delegate = self;
//    myTableView.dataSource = self;
//    myTableView.showsVerticalScrollIndicator = YES;
//    myTableView.autoresizingMask =UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
//    [self.view addSubview:myTableView];
//    
//    //初始化数据源
//    _dataArray = [[NSMutableArray alloc] initWithCapacity:0];
//    
//    //初始化WapsCustom方法 实现数据下载
//    wapCustom = [[WPListCustom alloc] init];
//    wapCustom.delegate = self;
//    //调用WapsCustom 的方法
//    [wapCustom loadCustomData];
//}
//#pragma mark 返回主页面
//- (void)buttonBack:(UIButton *)button
//{
//    if (button.tag == 102)
//    {
//        [wapCustom loadCustomData];
//        [myTableView reloadData];
//        myTableView.scrollsToTop = YES;
//    }
//    else
//    {
//        [self dismissViewControllerAnimated:YES
//                                 completion:^{
//                                     self.view = nil;
//                                     wapCustom = nil;
//                                 }];
//    }
//}
//
//#pragma mark -实现tableView的代理方法
////返回积分墙的总行数
//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
//{
//    return self.dataArray.count;
//}
////初始化每一行的数据
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    static NSString *cellId = @"cellID";
//    CustomOfferTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
//    if (cell == nil) {
//        cell = [[[NSBundle mainBundle] loadNibNamed:@"CustomOfferTableViewCell" owner:self options:nil] lastObject];
//        cell.iconImageView.frame = CGRectMake(6, 3, 63, 63);
//        cell.iconImageView.image = [UIImage imageNamed:@""];
//    }
//    
//    WapsModel *cellModel = (WapsModel *)[self.dataArray objectAtIndex:indexPath.row];
//    //把当前对象viewContrlloer传值给cell
//    [cell setCell:cellModel];
// 
//    return cell;
//}
//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    return 69.0f;
//}
//
//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    //当前页面弹出插屏广告
//    model = (WapsModel *)[self.dataArray objectAtIndex:indexPath.row];
//    self.selectModel = model;
//    [self showAction:model];
//}
//#pragma mark - 显示插屏广告
////显示插屏广告
//- (void)showAction:(id)sender
//{
//    WapsModel *model1 = (WapsModel *)sender;
//
//    //插屏广告画布
//    contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 200)];
//    [contentView setBackgroundColor:[UIColor whiteColor]];
//    
//    UIImageView *iconImageView = [self createImageView:CGRectMake(5, -20, 60, 60) imageName:@""];
//    [self downLoadImage:iconImageView url:model1.icon];
//    [contentView addSubview:iconImageView];
//    
//    UILabel *appNameLable = [self createLabel:CGRectMake(70, 10, 90, 20) title:model1.title font:14];
//    appNameLable.font = [UIFont boldSystemFontOfSize:16];
//    [contentView addSubview:appNameLable];
//    
//    NSArray *array = [model1.tip componentsSeparatedByString:@"*"];
//    NSArray *array1 = [[array objectAtIndex:0] componentsSeparatedByString:@"<"];
//    NSString *str1 = [array1 objectAtIndex:0];
//    NSArray *array2 = [[array objectAtIndex:1] componentsSeparatedByString:@"<"];
//    NSString *str2 = [array2 objectAtIndex:0];
//    NSString *str3 = [NSString stringWithFormat:@"%@*%@",str1,str2];
//    
//    UILabel *tipLable = [self createLabel:CGRectMake(8, 50, 270, 90) title:str3 font:14];
//    tipLable.numberOfLines = 0;
//    tipLable.layer.cornerRadius = 10;
//    tipLable.layer.masksToBounds = YES;
//    tipLable.backgroundColor = [UIColor grayColor];
//    [contentView addSubview:tipLable];
//    
//    UILabel *pointLable = [self createLabel:CGRectMake(40, 140, 80, 60) title:[NSString stringWithFormat:@"送%@积分",model1.points] font:16];
//    pointLable.backgroundColor = [UIColor clearColor];
//    pointLable.font = [UIFont boldSystemFontOfSize:15];
//    pointLable.textColor = [UIColor redColor];
//    [contentView addSubview:pointLable];
//    
//    UIButton *getButton = [self createButton:CGRectMake(135, 150, 100, 50) ImageName:@"" action:@selector(cellSelectDownLoad:) target:self title:@"立即获取"];
//    getButton.backgroundColor = [UIColor clearColor];
//    [contentView addSubview:getButton];
//
//
//    [[KGModal sharedInstance] showWithContentView:contentView andAnimated:YES];
//}
////下载应用
//- (void)cellSelectDownLoad:(UIButton *)button
//{
//    NSLog(@"downlaod");
//    //下载应用软件的接口
//    [downLoadWapsCustom listOnClick:self.selectModel.click_url];
//    NSLog(@"click_url is %@",self.selectModel.click_url);
//}
//
////下载高清图片
//- (void)downLoadImage:(UIImageView *)imageView url:(NSString *)url
//{
//    dispatch_async(dispatch_get_global_queue(0, 0), ^{
//        
//        NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];
//        
//        dispatch_sync(dispatch_get_main_queue(), ^{
//            imageView.layer.cornerRadius = 10;
//            imageView.layer.masksToBounds = YES;
//            imageView.image = [UIImage imageWithData:data];
//        });
//        
//    });
//    
//}
//
//#pragma mark -实现WapsCustomDelegate中的方法
////开始下载数据调用的方法
//- (void)isLoading:(BOOL)flg
//{
//    if (flg) {
//        if (actIndicator) {
//            return;
//        }
//        //添加下载菊花图
//        actIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
//        actIndicator.center = CGPointMake((self.view.frame.size.width)/2.0f,(self.view.frame.size.height)/2.0f);
//        actIndicator.color = [UIColor orangeColor];
//        [self.view addSubview:actIndicator];
//        [actIndicator startAnimating];
//    }else{
//        [actIndicator stopAnimating];
//        [actIndicator removeFromSuperview];
//    }
//}
////设置代理后返回的Json数据
//- (void)getCustomDataWithJson:(NSString *)offersJson
//{
////    NSLog(@"offersJson is %@",offersJson);
//}
////设置代理后返回的Array数据
//- (void)getCustomDataWithArray:(NSArray *)offersArray
//{
//    NSArray *recvArray = [NSArray arrayWithArray:offersArray];
//    if (self.dataArray.count>0) {
//        [self.dataArray removeAllObjects];
//    }
//    for (NSDictionary *dict in recvArray) {
//        WapsModel *model1 = [[WapsModel alloc] init];
//        [model1 setValuesForKeysWithDictionary:dict];
//        [self.dataArray addObject:model1];
//        RELEASE(model1);
//        model1 = nil;
//    }
//
//    //刷新数据
//    [myTableView reloadData];
//    //停止actIndicator转动
//    [actIndicator stopAnimating];
//}
//
//- (void)getCustomDataFaile:(NSString *)errorInfo
//{
//    NSLog(@"获取数据失败 %@",errorInfo);
//    //获取数据失败后再次请求网络
//    UIAlertView *alter =[[UIAlertView alloc] initWithTitle:@"" message:@"亲,网络太不给力了！" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
//    [alter show];
//    RELEASE(alter);
//}
////创建Button的方法
//- (UIButton *)createButton:(CGRect)frame
//                 ImageName:(NSString *)imageName
//                    action:(SEL)action
//                    target:(id)target
//                     title:(NSString *)title
//{
//    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
//    button.frame = frame;
//    [button setTitle:title forState:UIControlStateNormal];
//    [button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
//    [button setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
//    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
//    [button sizeToFit];
//    return button;
//}
////创建label
//- (UILabel *)createLabel:(CGRect)frame
//                   title:(NSString *)title
//                    font:(float)font
//{
//    UILabel *label = [[UILabel alloc]initWithFrame:frame];
//    label.text = title;
//    label.font = [UIFont systemFontOfSize:font];
//    //    label.adjustsFontSizeToFitWidth = YES;
//    return AUTORELEASE(label);
//}
//
////UIImageView frame image 交互
//- (UIImageView *)createImageView:(CGRect)frame
//                       imageName:(NSString *)imageName
//{
//    UIImageView *imageView = [[UIImageView alloc]initWithFrame:frame];
//    imageView.userInteractionEnabled = YES;
//    return imageView;
//}
//
//- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
//	return YES;
//}
//
//
//- (void)didReceiveMemoryWarning
//{
//    [super didReceiveMemoryWarning];
//    // Dispose of any resources that can be recreated.
//}
//
//@end
//
//
//@implementation WapsModel
//- (void)dealloc
//{
//    self.ad_id = nil;
//    self.ad_words = nil;
//    self.btn_txt = nil;
//    self.click_url = nil;
//    self.icon = nil;
//    self.points = nil;
//    self.points_name = nil;
//    self.size = nil;
//    self.tip = nil;
//    self.title = nil;
//    self.type = nil;
//    self.version = nil;
//    self.view_image = nil;
//    SUPER_DEALLOC;
//}
////model中未定义的key，次函数会处理
//- (void)setValue:(id)value forUndefinedKey:(NSString *)key
//{
//    ;
//}
//@end
//
//
//
//
//
